package conf

import (
	"fmt"
	"net/http"
	"ruoyi_zero/internal/svc"
)

func FileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {

		fmt.Println("url -- > ")
		fmt.Println(r.URL)
		//写字符串到前端
		////w.Write([]byte("hello world"))

		//访问单个文件
		filePath := "./static/dist"
		//http.ServeFile(w, r, filePath)
		//handler := http.StripPrefix(patern, http.FileServer(http.Dir(filePath)))
		//handler.ServeHTTP(w, r)
		patern := "static"

		handler := http.StripPrefix(patern, http.FileServer(http.Dir(filePath)))
		handler.ServeHTTP(w, r)
	}
}
